const app = getApp()
Page({
  /**
   * 页面的初始数据
   **/
  data: {
    userInfo: null,
  },
  /*
  * 生命周期函数--监听页面加载
  */
  onLoad: function (options) {
    let that = this;
    //判断用户是否登录
    let userInfo = app.globalData.userInfo;
    if (userInfo) {
      this.setData({
        userInfo: userInfo,
      })
    } else {
      wx.getUserInfo({
        success: function (res) {
          that.setData({
            userInfo: res.userInfo
          })
        }
      })
    }
  },
  goIndex() {
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
  promotion(){
    wx.navigateTo({
      url: '/pages/role/myPromotion/myPromotion'
    })
  },
  onShareAppMessage: function () {
    app.aldstat.sendEvent('代购页面-分享');

    wx.showShareMenu({
      withShareTicket: true
    });

    let phone = wx.getStorageSync('phone');
    console.log("分享的phone================", phone)
    return {
      title: "一线品牌一折起",//storeInfo.brandName,
      path: '/pages/index/index?inviteCode=' + phone,
      imageUrl: "https://goods.dingdian.xin/Fp3ptFYZ54XLi2L2OuAMjP_D45hJ?imageMogr2/thumbnail/400000@",
      success: res => {
        if (res.shareTickets) {
          console.log(res.shareTickets);
          wx.getShareInfo({
            shareTicket: res.shareTickets[0],
            success: d => {
              console.log(d);
            }
          })
        }
      }
    }
  }
})